package org.hxzon.demo.scala.traitdemo

abstract class Check {
  def check(): String = "Check Application Details..."
}
trait CreditCheck extends Check {
  override def check(): String = "Checked Credit..." + super.check()
}

trait EmploymentCheck extends Check {
  override def check(): String = "Checked Employment..." + super.check()
}

trait CriminalRecordCheck extends Check {
  override def check(): String = "Check Criminal Records..." + super.check()
}
object Decorator {
  def main(args: Array[String]): Unit = {
    val apartmentApplication = new Check with CreditCheck with CriminalRecordCheck
    val employmentApplication = new Check with CriminalRecordCheck with EmploymentCheck
    println(apartmentApplication check)
    //Check Criminal Records...Checked Credit...Check Application Details...
    println(employmentApplication check)
    //Checked Employment...Check Criminal Records...Check Application Details...
    //right to left
  }
}
